package com.dm0858.bianmin.mine.viewmodel;

import androidx.lifecycle.MutableLiveData;
import androidx.lifecycle.ViewModel;

import com.dm0858.bianmin.app.MyApp;
import com.dm0858.bianmin.mine.bean.MyReleaseBeanData;
import com.dm0858.bianmin.mine.bean.PostManagerBeanData;
import com.dm0858.bianmin.mine.listener.IResultListener;
import com.dm0858.bianmin.mine.model.MineModel;
import com.dm0858.bianmin.mine.network.Retrofit;

import java.util.List;

public class PostManagerViewModel extends ViewModel {

    private Retrofit retrofit;

    public PostManagerViewModel() {
        if (retrofit == null) retrofit = new Retrofit();
    }

    private MutableLiveData<List<PostManagerBeanData.DataBean>> releaseList;

    public MutableLiveData<List<PostManagerBeanData.DataBean>> getReleaseList() {
        if (releaseList == null) {
            releaseList = new MutableLiveData<>();
            releaseList.setValue(null);
        }
        return releaseList;
    }

    public void setReleaseList(List<PostManagerBeanData.DataBean> releaseList) {
        getReleaseList().setValue(releaseList);
    }

    /**
     *
     * @description 获取我的发布
     * @author 迪迪丶Sir
     * @e-mail asd969709719@qq.com
     * @since 2020-05-18
     **/
    public void userArticle(int page) {
        MineModel.postManager(retrofit, MyApp.userid, "", "", page, object -> setReleaseList((List<PostManagerBeanData.DataBean>) object));
    }
}
